# "Credit Claiming by Labeling"
# Virginia Oliveros, Rebecca Weitz-Shapiro, and Matthew S. Winters
# Comparative Political Studies

# Figure 2

library(tidyverse)

# Load Data
cc.data <- haven::read_dta("CreditClaiming_Replication.dta")

# Filter Data to Respondents Who Saw the Image
cc.data <- cc.data %>% filter(saw_box==1)

# Create Proportions
Ethical <- (table(cc.data$naming_ethical)/length(cc.data$naming_ethical))*100
Common <- (table(cc.data$naming_common)/length(cc.data$naming_common))*100
Important <- (table(cc.data$naming_important)/length(cc.data$naming_important))*100

barplot (Ethical, main="Ethical", ylim=c(0,50))
barplot (Common, main="Common", ylim=c(0,50))
barplot (Important, main="Important", ylim=c(0,50))

test <- cbind(Ethical,Common, Important)

tiff("figure2.tiff", height=3.5, width=6, units="in", res=300)

barplot(test,beside=T, ylim=c(0,50), ylab="Percentage of Responses")

dev.off()

